import axios from "./http.js";
import _ from "lodash";

/*
 * 预警管理
 */
// 获取线下店铺推广码列表
// export function getQrcodeList(config) {
//   let url = "/bs/qrcode/channel/list";
//   const opts = _.merge({}, config || {});

//   return axios.get(url, opts);
// }
// // 获取推广详情
// export function getQrcodeDetail(config) {
//   let url = "/bs/qrcode/channel/";
//   const opts = _.merge({}, config || {});
//   url = url + opts.params.id;
//   delete opts.params.id;

//   return axios.get(url, opts);
// }
// // 添加线下店铺推广码
// export function addQrcode(data, config) {
//   let url = "/bs/qrcode/generate";

//   data = data || {};
//   config = config || {};
//   return axios.post(url, data, config);
// }
// // 编辑线下店铺推广码
// export function updateQrcode(data, config) {
//   let url = "/bs/qrcode/channel/update";

//   data = data || {};
//   config = config || {};
//   return axios.post(url, data, config);
// }
// 获取渠道列表
export function getChannelList(config) {
  let url = "/bs/channel/v1/list";
  const opts = _.merge({}, config || {});

  return axios.get(url, opts);
}
// 获取渠道详情详情
export function getChannelDetail(config) {
  let url = "/bs/channel/v1/view";
  const opts = _.merge({}, config || {});
  // url = url + opts.params.id;
  // delete opts.params.id;

  return axios.get(url, opts);
}
// 添加渠道
export function addChannel(data, config) {
  let url = "/bs/channel/v1/saveOrUpdate";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 编辑渠道
export function updateChannel(data, config) {
  let url = "/bs/channel/v1/saveOrUpdate";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 修改渠道密码
export function updatePassword(data, config) {
  let url = "/bs/channel/v1/changePassword";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 修改渠道状态
export function updateChannelStatus(data, config) {
  let url = "/bs/channel/v1/changeStatus";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}

// 获取文案列表
export function getH5docList(config) {
  let url = "/bs/platform/h5/list";
  const opts = _.merge({}, config || {});

  return axios.get(url, opts);
}
// 添加文案
export function addH5doc(data, config) {
  let url = "/bs/platform/h5/save";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 编辑文案
export function updateH5doc(data, config) {
  let url = "/bs/platform/h5/save";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 删除文案
export function deleteH5doc(data, config) {
  let url = "/bs/platform/h5/delete/";

  data = data || {};
  config = config || {};
  url = url + data.id;
  delete data.id;
  return axios.post(url, data, config);
}
// 获取文案
export function getH5docDetail(config) {
  let url = "/bs/platform/h5/view/";
  const opts = _.merge({}, config || {});
  url = url + opts.params.id;
  delete opts.params.id;

  return axios.get(url, opts);
}

// 获取海报类型
// export function getBillList(config) {
//   let url = "/bs/poster/list";
//   const opts = _.merge({}, config || {});

//   return axios.get(url, opts);
// }
// 获取海报类型
export function getBillList(config) {
  let url = "/bs/channel/v1/poster/list";
  const opts = _.merge({}, config || {});

  return axios.get(url, opts);
}
// 获取推广计划，如是二维码还是h5链接的填写页面来推广
export function getPlanData(config) {
  let url = "/bs/channel/v1/material/viewQrCode";
  const opts = _.merge({}, config || {});

  return axios.get(url, opts);
}
// 获取推广计划里面的海报数据
export function getBillData(config) {
  let url = "/bs/channel/v1/material/viewPoster";
  const opts = _.merge({}, config || {});

  return axios.get(url, opts);
}

// // 获取海报
// export function getBill(config) {
//   let url = "/bs/qrcode/channel/poster";
//   const opts = _.merge({}, config || {});

//   return axios.get(url, opts);
// }

// 获取h5页面类型列表
// export function getH5PageTypeList(config) {
//   let url = "/bs/qrcode/channelClass/list";
//   const opts = _.merge({}, config || {});

//   return axios.get(url, opts);
// }
// 获取h5页面类型列表
export function getH5PageTypeList(config) {
  let url = "/bs/channel/v1/material/list";
  const opts = _.merge({}, config || {});

  return axios.get(url, opts);
}

// // 下载渠道
// export function downloadChannel(options) {
//   let url = "/bs/qrcode/channel/export";
//   const opts = _.merge({}, options || {});
//   opts.responseType = "blob";
//   return axios.get(url, opts);
// }
// 下载渠道
export function downloadChannel(options) {
  let url = "/bs/channel/v1/export";
  const opts = _.merge({}, options || {});
  opts.responseType = "blob";
  return axios.get(url, opts);
}

// 获取资料提交页浏览数
export function getMaterialViewCount(config) {
  let url = "/bs/channel/v1/materialViewCount";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
// 获取资料提交页浏览数(按天统计)
export function getMaterialViewCountByDate(config) {
  let url = "/bs/channel/v1/materialViewCountByDate";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}

// 获取h5海报浏览数
export function getPosterViewCount(config) {
  let url = "/bs/channel/v1/posterViewCount";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
// 获取h5海报浏览数(按天统计)
export function getPosterViewCountByDate(config) {
  let url = "/bs/channel/v1/posterViewCountByDate";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}

// 获取平台结算方式列表
export function getPlatformSettlementsList(config) {
  let url = "/bs/channel/v1/platformSettlements";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
// 获取渠道的平台结算
export function getChannelSettlementsList(config) {
  let url = "/bs/channel/v1/querySettlement";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
// 渠道新增平台结算方式
export function addSettleStyle(data, config) {
  let url = "/bs/channel/v1/addSettlement";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
